/**
 * 
 */
package com.taobao.snowsnow.hibernate.service.impl;

import java.util.List;

import org.hibernate.criterion.Criterion;

import com.taobao.snowsnow.hibernate.dao.TradeDao;
import com.taobao.snowsnow.hibernate.pojo.Trade;
import com.taobao.snowsnow.hibernate.service.TradeService;

/**
 * @author Tux
 *
 * 创建时间: 2011-4-29 上午09:55:17
 */
public class TradeServiceImpl extends BaseServiceImpl implements TradeService {
	private TradeDao tdao;
	
	public List<Trade> findAll() {
		try {
			return tdao.findAll();
		} catch(Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Trade findById(int id) {
		try {
			return tdao.findById(id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findById(int id)");
		}
		return null;
	}
	
	public List<Trade> findByName(String name) {
		try {
			return tdao.findByName(name);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByName(String name)");
		}
		return null;
	}

	public long getTotal()  {
		try {
			return tdao.getTotal();
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at getTotal()");
		}
		return -1;
	}

	/* (non-Javadoc)
	 * @see com.taobao.snowsnow.hibernate.service.TradeService#paging(int, int)
	 */
	public List<Trade> paging(int page, int limit)  {
		try {
			return tdao.paging(page, limit);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at paging(int page, int limit)");
		}
		return null;
	}

	public void setTdao(TradeDao cdao) {
		this.tdao = cdao;
	}

	public TradeDao getTdao() {
		return tdao;
	}

	@Override
	public Trade getFirstObject() {
		try {
			return tdao.getFirstObject();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade getFirstObject()");
		}
		return null;
	}

	@Override
	public Trade getLastObject() {
		try {
			return tdao.getLastObject();
		} catch(Exception e) {
			e.printStackTrace();
			System.out.println("Trade getLastObject()");
		}
		return null;
	}

	@Override
	public List<Trade> findByTaoBaoID(String nick) {
		try {
			return tdao.findByTaoBaoID(nick);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade findByTaoBaoID()");
		}
		return null;
	}

	@Override
	public Trade findByTid(Long tid) {
		try {
			return tdao.findByTid(tid);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade findByTid()");
		}
		return null;
	}

	@Override
	public Trade findByMultiTids(long tid) {
		try {
			return tdao.findByMultiTids(tid);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade findByMultiTids()");
		}
		return null;
	}

	@Override
	public Trade findByTaoBaoIDAndStatus(String nick, int status) {
		try {
			return tdao.findByTaoBaoIDAndStatus(nick, status);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade findByTaoBaoIDAndStatus()");
		}
		return null;
	}

	@Override
	public List<Trade> findByCriteria(List<Criterion> expression) {
		try {
			return tdao.findByCriteria(expression);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Trade findByCriteria()");
		}
		return null;
	}
}
